﻿using Huirui.Cavan.Core.MyLinq;
using Huirui.Cavan.Core.Persistent;
using Huirui.Cavan.Domain.MainBoundedContext.SearchModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    public class BaseCodeRuleSpecification : ISpecification<BaseCodeRule, BaseCodeRuleSearch>
    {
        public BaseCodeRuleSearch SearchParams
        {
            get;
            set;
        }

        public System.Linq.Expressions.Expression<Func<BaseCodeRule, bool>> Expression
        {
            get 
            {
                IQueryBuilder<BaseCodeRule> queryBuilder = QueryBuilder.Create<BaseCodeRule>();

                if (null != SearchParams)
                {
                    if (SearchParams.Type > 0)
                    {
                        queryBuilder = queryBuilder.Equals(bcr => (int)bcr.Type, SearchParams.Type);
                    }
                }

                return queryBuilder.Expression.Expand();
            }
        }
    }
}
